package ee.ut.math.chess.base.model;

import java.io.Serializable;

public class Move implements Serializable{
	private static final long serialVersionUID = 1L;
	
	private Position start;
	private Position end;
	private SpecialMoveType specialMoveType;

	public Move(String moveString) {
		String[] tmp = moveString.split("-");
		start = new Position(tmp[0]);
		end = new Position(tmp[1]);
	}

	public Move(int x1, int y1, int x2, int y2) {
		start = new Position(x1, y1);
		end = new Position(x2, y2);
	}

	public Move(int x1, int y1, int x2, int y2, SpecialMoveType specialMoveType) {
		this(x1, y1, x2, y2);
		this.specialMoveType = specialMoveType;
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof Move)) {
			return false;
		}
		Move move2 = (Move) obj;
		return start.equals(move2.start) && end.equals(move2.end);
	}

	public int getX1() {
		return start.getX();
	}

	public int getY1() {
		return start.getY();
	}

	public int getX2() {
		return end.getX();
	}

	public int getY2() {
		return end.getY();
	}

	public SpecialMoveType getSpecialMoveType() {
		return specialMoveType;
	}

	public void setSpecialMoveType(SpecialMoveType specialMoveType) {
		this.specialMoveType = specialMoveType;
	}
	
	public Position getStart() {
		return start;
	}
	@Override
	public String toString() {
		return start + "-" + end;
	}
}
